package com.elasticsearch.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;

/**
 * @author xiaochi
 * @date 2022/3/12 16:44
 * @desc UserPojo
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Document(indexName = "blogs",type = "user") // 索引名称小写，类属性名称小写
public class UserPojo implements Serializable {

    private static final long serialVersionUID = -2264733446372494644L;

    @Id
    private Long id;

    @Field(type = FieldType.Text,analyzer = "ik_max_word") // 分词对应类型 text，不分词不创建索引对应 Keyword
    private String name;

    @Field(type = FieldType.Integer)
    private Integer age;

    @Field(type = FieldType.Keyword,index = false) // 密码不用分词不用创建索引
    private String password;

    @Field(type = FieldType.Keyword,index = false)
    private String nickname;
}
